import subprocess

try:
    # 运行外部命令
    output = subprocess.check_output(["ls", "-z"], text=True)
    print("命令输出：")
    print(output)
except subprocess.CalledProcessError as e:
    print("命令执行失败！")
    print("错误信息：")
    print(e.output)
except FileNotFoundError:
    print("命令未找到！")